package com.huawei.appmarket.service.store.awk.card;

import android.content.Context;
import android.os.Handler;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.huawei.appgallery.foundation.account.bean.UserSession;
import com.huawei.appgallery.foundation.card.base.card.BaseDistCard;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appgallery.purchasehistory.api.IPurchaseHistoryManager;
import com.huawei.appgallery.purchasehistory.api.IPurchaseHistoryProtocol;
import com.huawei.fastengine.fastview.download.utils.PackageUtils;
import java.lang.ref.WeakReference;
import o.azb;
import o.bfs;
import o.AccountBussinessListener;
import o.ccp;
import o.cgy;
import o.cgz;
import o.chy;
import o.ContentManager;
import o.ecr;
import o.eoj;
import o.ewm.j;
import o.ewm.n;
import o.fam;
import o.fho;
import o.fhq;
import o.fjb;

public class PurchaseHistoryCard extends BaseDistCard {
    private Handler ʼ = new Handler();
    private TextView ʽ;
    private RelativeLayout ˋ;
    private TextView ॱॱ;

    static class a implements OnClickListener {
        private WeakReference<PurchaseHistoryCard> ॱ;

        public a(PurchaseHistoryCard purchaseHistoryCard) {
            this.ॱ = new WeakReference(purchaseHistoryCard);
        }

        public void onClick(View view) {
            PurchaseHistoryCard purchaseHistoryCard = (PurchaseHistoryCard) this.ॱ.get();
            if (purchaseHistoryCard != null) {
                if (UserSession.getInstance().isLoginSuccessful()) {
                    purchaseHistoryCard.ˋ();
                    return;
                }
                eoj.ˋ().ˎ("PurchaseHistoryCard", new c(purchaseHistoryCard));
                bfs.ˋ().ॱ(purchaseHistoryCard.ʼॱ);
            }
        }
    }

    static class c implements AccountBussinessListener {
        private WeakReference<PurchaseHistoryCard> ˏ;

        public c(PurchaseHistoryCard purchaseHistoryCard) {
            this.ˏ = new WeakReference(purchaseHistoryCard);
        }

        public void onAccountBusinessResult(ccp o_ccp) {
            eoj.ˋ().ˊ("PurchaseHistoryCard");
            PurchaseHistoryCard purchaseHistoryCard = (PurchaseHistoryCard) this.ˏ.get();
            if (purchaseHistoryCard != null && 102 == o_ccp.ˎ) {
                purchaseHistoryCard.ʼ.post(new d(purchaseHistoryCard));
            }
        }
    }

    static class d implements Runnable {
        private PurchaseHistoryCard ˋ;

        public d(PurchaseHistoryCard purchaseHistoryCard) {
            this.ˋ = purchaseHistoryCard;
        }

        public void run() {
            this.ˋ.ˋ();
        }
    }

    public PurchaseHistoryCard(Context context) {
        super(context);
    }

    public cgz ˏ(View view) {
        ʽ(view);
        this.ˋ = (RelativeLayout) view.findViewById(j.ˊˮ);
        this.ॱॱ = (TextView) view.findViewById(j.ˇˊ);
        this.ʽ = (TextView) view.findViewById(j.ʽˈ);
        return this;
    }

    public void ॱ(chy o_chy) {
        View ˉ = ˉ();
        if (ˉ != null) {
            ˉ.setOnClickListener(new a(this));
        }
    }

    private void ˋ() {
        fhq ˏ = fho.ˏ();
        ((IPurchaseHistoryManager) ˏ.ˋ("PurchaseHistory").ॱ(IPurchaseHistoryManager.class)).init(new ecr());
        fjb ˎ = ˏ.ˋ("PurchaseHistory").ˎ("purchaseHistoryActivity");
        IPurchaseHistoryProtocol iPurchaseHistoryProtocol = (IPurchaseHistoryProtocol) ˎ.ˊ();
        iPurchaseHistoryProtocol.setShowMenu(true);
        iPurchaseHistoryProtocol.setRightColumnTitle(ContentManager.getInstant().getContext().getResources().getString(n.ʽꓸ));
        iPurchaseHistoryProtocol.setLeftColumnTitle(ContentManager.getInstant().getContext().getResources().getString(n.ʽᐧ));
        iPurchaseHistoryProtocol.setShowFragmenntFlag(0);
        if (PackageUtils.HWGAMEBOX_PACKAGE_NAME.equals(ContentManager.getInstant().getContext().getPackageName())) {
            iPurchaseHistoryProtocol.setCurrentPosition(3);
        } else {
            iPurchaseHistoryProtocol.setCurrentPosition(4);
        }
        fam.ॱ().ॱ(this.ʼॱ, null, ˎ, true);
    }

    private int ˊ() {
        int i = this.ʼॱ.getResources().getConfiguration().orientation;
        if (i == 2) {
            return (azb.ॱ(this.ʼॱ) * 1) / 2;
        }
        if (i == 1) {
            return (int) (((float) azb.ॱ(this.ʼॱ)) * 0.8f);
        }
        return (int) (((float) azb.ॱ(this.ʼॱ)) * 0.8f);
    }

    private int ˎ() {
        Context ˋ = ContentManager.getInstant().getContext();
        return ((((((ˊ() - ˋ.getResources().getDimensionPixelOffset(o.ewm.d.ʾ)) - ˋ.getResources().getDimensionPixelOffset(o.ewm.d.ʿॱ)) - ˋ.getResources().getDimensionPixelOffset(o.ewm.d.ᐝˊ)) - ˋ.getResources().getDimensionPixelOffset(o.ewm.d.ᐝˊ)) - ˋ.getResources().getDimensionPixelOffset(o.ewm.d.ˈॱ)) - ˋ.getResources().getDimensionPixelOffset(o.ewm.d.ᐝॱ)) - ˋ.getResources().getDimensionPixelOffset(o.ewm.d.ʿ);
    }

    public void ˏ(CardBean cardBean) {
        int ॱ = ॱ(this.ॱॱ, ContentManager.getInstant().getContext().getResources().getString(n.ʽꜞ));
        int ॱ2 = ॱ(this.ʽ, ContentManager.getInstant().getContext().getResources().getString(n.ˊʿ));
        int ˎ = ˎ();
        int i = ˎ / 3;
        int i2 = ˎ - i;
        if (ॱ > i2) {
            this.ॱॱ.setWidth(i2);
            if (ॱ2 > i) {
                this.ʽ.setWidth(i);
                return;
            } else {
                this.ʽ.setWidth(ॱ2);
                return;
            }
        }
        this.ॱॱ.setWidth(ॱ);
        ॱ = ˎ - ॱ;
        if (ॱ2 > ॱ) {
            this.ʽ.setWidth(ॱ);
        } else {
            this.ʽ.setWidth(ॱ2);
        }
    }

    private int ॱ(TextView textView, String str) {
        if (textView == null || cgy.ˎ(str)) {
            return 0;
        }
        return (((int) textView.getPaint().measureText(str)) + textView.getPaddingLeft()) + textView.getPaddingRight();
    }
}
